class Solution 
{
public:
    int dismantlingAction(string arr)
    {
        map<char, int> m;
        int ans = 0, l = 0, r = 0;
        while (r < arr.size())
        {
            if (m.find(arr[r]) != m.end())
                l = max(l, m[arr[r]] + 1);

            m[arr[r++]] = r;
            ans = max(r - l, ans);
        }
        return ans;
    }
};